<template>
	<view class="playlet">
		<view class="top">
			<comHead :title="'短剧'" :isLeft="true" :isRight="false"></comHead>
			<view class="pad">
				<view class="searchBox" @click="toSearch">
					<input type="text" :placeholder="'请输入剧名搜索'" disabled=""/>
					<image src="https://siha.vxmeng.com/static/privacy/msearch.png" mode="widthFix"></image>
				</view>
				
				<view class="navBar" v-if="!isExpand">
					<view class="l">
						<view class="navItem" @click="toggle(index)" :class="type==index?'on':''" v-for="(item,index) in 8">
							<view class="text">精选</view>
						</view>
					</view>
					<image @click="onExpand(true)" src="https://siha.vxmeng.com/static/playlet/menu.png" mode="widthFix"></image>
				</view>
				
				<view class="category" v-else>
					<view class="t">
						<text>剧集频道</text>
						<image @click="onExpand(false)" src="https://siha.vxmeng.com/static/playlet/menu.png" mode="widthFix"></image>
					</view>
					<view class="categoryList">
						<view class="item" @click="toggle(index)" :class="type==index?'on':''" v-for="(item,index) in 15">精选</view>
					</view>
				</view>
			</view>
		</view>
		<view class="content" :class="isExpand?'on':''">
			<swiper v-if="type==0" class="banner" circular :autoplay="autoplay" :interval="interval">
				<swiper-item class="swiper-item" v-for="(item,index) in imgs">
					<image :src="getImg(item)" mode="aspectFill"></image>
				</swiper-item>
			</swiper>
			
			<view class="titBtn" v-if="type==0">
				<view class="btn_item" @click="toggleList(1)" :class="active==1?'on':''">
					<image src="https://siha.vxmeng.com/static/more/hot.png" mode="widthFix"></image>
					热门推荐
					</view>
				<view class="btn_item" @click="toggleList(2)" :class="active==2?'on':''">历史记录</view>
				<!-- <view class="btn_item" @click="toLove" :class="active==3?'on':''">我的收藏</view> -->
				<view class="btn_item" @click="toggleList(3)" :class="active==3?'on':''">我的收藏</view>
			</view>
			
			<view class="list1" v-if="active==1">
				<view class="item" v-for="item in 8" @click="toWatch(item)">
					<view class="img">
						<image src="https://siha.vxmeng.com/static/shu.jpg" mode="aspectFill"></image>
					</view>
					<view class="info">
						<view class="hot">热播</view>
						<text>这是剧名</text>
					</view>
				</view>
			</view>
			
			<view class="list2" v-if="active!=1">
				<view class="item" v-for="item in 6">
					<view class="img">
						<image src="https://siha.vxmeng.com/static/shu.jpg" mode="aspectFill"></image>
					</view>
					<view class="info">
						<view class="tit">这是剧名</view>
						<view class="intro">
							前世她是豪门千金，因家族纷争和爱情背叛，被陷害身亡。今世重生回到二十岁...
						</view>
						<view class="other">观看至第{{4}}集 / 共{{93}}集</view>
						<view class="btns">
							<view class="btn">
								<image src="https://siha.vxmeng.com/static/playlet/zj.png" mode="widthFix"></image>
								<text>追剧</text>
							</view>
							<view class="btn">
								<image src="https://siha.vxmeng.com/static/playlet/no-sc.png" mode="widthFix"></image>
								<text>收藏</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isExpand: false,
				type: 0,
				active: 1,
				imgs: ['https://siha.vxmeng.com/static/heng.jpg','https://siha.vxmeng.com/static/heng.jpg'],
				list: [],
			}
		},
		onReady() {
			if(this.$music.bgmInstance){
				this.$music.bgmInstance.destroy();
				this.$music.bgmInstance = null;
			}
		},
		onShow() {
			setTimeout(()=>{
				if(this.$music.bgmInstance){
					this.$music.bgmInstance.destroy();
					this.$music.bgmInstance = null;
				}
			}, 0)
		},
		methods: {
			toWatch(item){
				this.comLink('/pages/playlet/watch')
			},
			toSearch(){
				this.comLink('/pages/playlet/search')
			},
			onExpand(e){
				this.isExpand = e
			},
			toggle(index){
				this.type = index
			},
			toggleList(e){
				this.active = e
			},
			toLove(){
				this.comLink('/pages/playlet/collection')
			}
		}
	}
</script>

<style lang="less" scoped>
.playlet{
	min-height: 100vh;
	width: 100vw;
	
	.top{
		position: sticky;
		top: 0;
		background: url(https://siha.vxmeng.com/static/index/zbg.png) center top/ cover;
		z-index: 1;
		overflow: hidden;
		.pad{
			padding: 0 30rpx;
			.searchBox{
				width: 100%;
				height: 80rpx;
				background: linear-gradient(97deg, #2A2832 0%, rgba(30, 36, 44, 0.65) 100%);
				display: flex;
				align-items: center;
				border-radius: 40rpx;
				padding: 0 16rpx 0 40rpx;
				input{
					flex: 1;
					height: 100%;
					
				}
				image{
					width: 40rpx;
					padding: 20rpx;
				}
			}
			
			.navBar{
				height: 48rpx;
				width: 100%;
				position: relative;
				display: flex;
				margin: 20rpx 0;
				
				.l{
					flex: 1;
					height: 100%;
					display: flex;
					overflow-x: auto;
					overflow-y: visible;
					&::-webkit-scrollbar{
						display: none;
					}
					
					.navItem{
						padding: 0 20rpx;
						flex-shrink: 0;
						color: #fff;
						font-size: 28rpx;
						opacity: .6;
						&.on{
							opacity: 1;
							font-size: 32rpx;
							position: relative;
							&::after{
								content: "";
								width: 30rpx;
								border: 3rpx solid #fff;
								position: absolute;
								bottom: 0;
								left: 50%;
								transform: translateX(-50%);
							}
						}
						.text{
							line-height: 48rpx;
						}
					}
				}
				image{
					width: 56rpx;
				}
			}
			
			.category{
				color: #fff;
				.t{
					height: 48rpx;
					width: 100%;
					margin: 20rpx 0;
					position: relative;
					display: flex;
					justify-content: space-between;
					image{
						width: 56rpx;
					}
				}
				.categoryList{
					height: 400rpx;
					display: flex;
					flex-wrap: wrap;
					.item{
						height: 68rpx;
						width: calc((100% - 90rpx) / 4);
						margin-right: 30rpx;
						margin-bottom: 30rpx;
						font-size: 28rpx;
						background: rgba(34, 37, 46, 0.5);
						border-radius: 10rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						&.on{
							background: linear-gradient(307deg, #62B6FC -2%, #5F58FD 74%, #5F58FD 94%);
							-webkit-background-clip: text;
							-webkit-text-fill-color: transparent;
						}
						&:nth-child(4n){
							margin-right: 0;
						}
					}
				}
			}
		}
	}
	
	.content{
		padding: 0 30rpx;
		&.on{
			margin-top: -400rpx;
		}
		.banner{
			width: 100%;
			height: 400rpx;
			image{
				width: 100%;
				height: 100%;
				border-radius: 10rpx;
			}
		}
		
		.titBtn{
			height: 64rpx;
			width: 100%;
			margin: 20rpx 0;
			display: flex;
			align-items: center;
			.btn_item{
				display: flex;
				align-items: center;
				margin-right: 30rpx;
				color: #767B82;
				image{
					width: 40rpx;
					margin-right: 10rpx;
				}
				&.on{
					color: #fff;
				}
			}
		}
		
		.list1{
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			
			.item{
				width: 48%;
				height: 488rpx;
				border-radius: 16rpx;
				overflow: hidden;
				margin-bottom: 24rpx;
				color: #fff;
				background-color: #22252E;
				.img{
					height: 420rpx;
					width: 100%;
					image{
						width: 100%;
						height: 100%;
					}
				}
				.info{
					height: 68rpx;
					display: flex;
					align-items: center;
					box-shadow: 0px 4rpx 4rpx 12rpx rgba(0, 0, 0, 0.2);
					view{
						font-size: 24rpx;
						width: 84rpx;
						height: 30rpx;
						line-height: 32rpx;
						text-align: center;
						margin: 0 10rpx;
						border-radius: 15rpx;
						background: linear-gradient(287deg, #62B6FC 0%, #5F58FD 77%, #5F58FD 98%);
					}
				}
			}
		}
		
		.list2{
			width: 100%;
			.item{
				height: 280rpx;
				margin-top: 20rpx;
				color: #fff;
				display: flex;
				.img{
					width: 200rpx;
					height: 280rpx;
					margin-right: 20rpx;
					image{
						width: 100%;
						height: 100%;
					}
				}
				.info{
					flex: 1;
					.tit{
						font-size: 36rpx;
					}
					.intro{
						font-size: 24rpx;
						color: #999999;
						margin-top: 20rpx;
					}
					.other{
						font-size: 24rpx;
						margin-top: 20rpx;
					}
					.btns{
						margin-top: 40rpx;
						display: flex;
						.btn{
							width: 144rpx;
							height: 56rpx;
							margin-right: 24rpx;
							border-radius: 10rpx;
							background: linear-gradient(270deg, #5F58FD 0%, #62B6FC 100%);
							display: flex;
							justify-content: center;
							align-items: center;
							image{
								width: 24rpx;
								margin-right: 10rpx;
							}
						}
					}
				}
			}
		}
	}
}
</style>
